home *** CD-ROM | disk | FTP | other *** search
- #include "Callbacks.h"
-
-
- // Ignore first two params to CallUniversalProc().
- asm void PrologGlue() {
- addi sp, sp, 0x08
- blr
- }
-
- // Restore first two params to CallUniversalProc().
- asm void EpilogGlue() {
- subi sp, sp, 0x08
- blr
- }
-
- pascal void MyCreateCallback( FWData theFWData )
- {
- PrologGlue();
-
- // Do something with incoming data...
- //HandleCreate( theFWData );
-
- EpilogGlue();
- }
-
- void Subscribe() {
- OSErr theErr = noErr;
- SelectorFunctionUPP myGestaltUPP;
- FWSubscribePtr theFWSubscribePtr;
-
- theErr = ::Gestalt( FS_SIGNATURE, ( long * )&myGestaltUPP );
-
- if ( theErr == noErr ) {
- //::DebugStr( "\pRemoving callback address from extension..." );
-
- theFWSubscribePtr = ( FWSubscribePtr )NewPtr( sizeof( FWSubscribe ) );
-
- if ( theFWSubscribePtr != nil ) {
- theFWSubscribePtr->theAction = kCreateFlag;
- theFWSubscribePtr->theCallbackAddr = ( long * )&MyCreateCallback;
- theErr = CallSelectorFunctionProc( myGestaltUPP, GESTALT_ADD_CALLBACK, ( long * )theFWSubscribePtr );
- DisposePtr( ( Ptr )theFWSubscribePtr );
- }
- }
- }
-
- void Unsubscribe() {
- OSErr theErr = noErr;
- SelectorFunctionUPP myGestaltUPP;
- FWSubscribePtr theFWSubscribePtr;
-
- theErr = ::Gestalt( FS_SIGNATURE, ( long * )&myGestaltUPP );
-
- if ( theErr == noErr ) {
- //::DebugStr( "\pRemoving callback address from extension..." );
-
- theFWSubscribePtr = ( FWSubscribePtr )NewPtr( sizeof( FWSubscribe ) );
-
- if ( theFWSubscribePtr != nil ) {
- theFWSubscribePtr->theAction = kCreateFlag;
- theFWSubscribePtr->theCallbackAddr = ( long * )&MyCreateCallback;
- theErr = CallSelectorFunctionProc( myGestaltUPP, GESTALT_REMOVE_CALLBACK, ( long * )theFWSubscribePtr );
- DisposePtr( ( Ptr )theFWSubscribePtr );
- }
- }
- }
-